using IrisGenerator.Common.Tools;
namespace IrisGenerator.Common.Modules
{
    
    
    public partial class FormaterReplacementChars {
        
        private System.Nullable<System.Guid> _repChaId;
        
        private string _forConConfigKey;
        
        private FormaterConfiguration _formaterConfiguration;
        
        private ReplacementChars _replacementChars;
        
        public virtual System.Nullable<System.Guid> RepChaId {
            get {
                return _repChaId;
            }
            set {
                _repChaId = value;
            }
        }
        
        public virtual string ForConConfigKey {
            get {
                return _forConConfigKey;
            }
            set {
                _forConConfigKey = value;
            }
        }
        
        public virtual FormaterConfiguration FormaterConfiguration {
            get {
                if ((this._formaterConfiguration == null)) {
                    this._formaterConfiguration = FormaterConfiguration.Load(this._forConConfigKey);
                }
                return this._formaterConfiguration;
            }
            set {
                _formaterConfiguration = value;
            }
        }
        
        public virtual ReplacementChars ReplacementChars {
            get {
                if ((this._replacementChars == null)) {
                    this._replacementChars = ReplacementChars.Load(this._repChaId);
                }
                return this._replacementChars;
            }
            set {
                _replacementChars = value;
            }
        }
        
        private void Clean() {
            this.RepChaId = null;
            this.ForConConfigKey = string.Empty;
            this.FormaterConfiguration = null;
            this.ReplacementChars = null;
        }
        
        private void Fill(System.Data.DataRow dr) {
            this.Clean();
            if ((dr["REP_CHA_ID"] != System.DBNull.Value)) {
                this.RepChaId = ((System.Nullable<System.Guid>)(dr["REP_CHA_ID"]));
            }
            if ((dr["FOR_CON_CONFIG_KEY"] != System.DBNull.Value)) {
                this.ForConConfigKey = ((string)(dr["FOR_CON_CONFIG_KEY"]));
            }
        }
        
        public static FormaterReplacementCharsCollection Select_FORMATER_REPLACEMENT_CHARS_By_FOR_CON_CONFIG_KEY(string FOR_CON_CONFIG_KEY) {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                System.Data.DataSet ds = dbo.Select_FORMATER_REPLACEMENT_CHARS_By_FOR_CON_CONFIG_KEY(FOR_CON_CONFIG_KEY);
                FormaterReplacementCharsCollection collection = new FormaterReplacementCharsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        FormaterReplacementChars obj = new FormaterReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static FormaterReplacementCharsCollection Select_FORMATER_REPLACEMENT_CHARS_By_REP_CHA_ID(System.Nullable<System.Guid> REP_CHA_ID) {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                System.Data.DataSet ds = dbo.Select_FORMATER_REPLACEMENT_CHARS_By_REP_CHA_ID(REP_CHA_ID);
                FormaterReplacementCharsCollection collection = new FormaterReplacementCharsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        FormaterReplacementChars obj = new FormaterReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static FormaterReplacementCharsCollection GetAll() {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                System.Data.DataSet ds = dbo.FORMATER_REPLACEMENT_CHARS_Select_All();
                FormaterReplacementCharsCollection collection = new FormaterReplacementCharsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        FormaterReplacementChars obj = new FormaterReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static FormaterReplacementChars Load(System.Nullable<System.Guid> REP_CHA_ID, string FOR_CON_CONFIG_KEY) {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                System.Data.DataSet ds = dbo.FORMATER_REPLACEMENT_CHARS_Select_One(REP_CHA_ID, FOR_CON_CONFIG_KEY);
                FormaterReplacementChars obj = null;
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        obj = new FormaterReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[0]);
                    }
                }
                return obj;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Load() {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                System.Data.DataSet ds = dbo.FORMATER_REPLACEMENT_CHARS_Select_One(this.RepChaId, this.ForConConfigKey);
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        this.Fill(ds.Tables[0].Rows[0]);
                    }
                }
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Insert() {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                dbo.FORMATER_REPLACEMENT_CHARS_Insert(this.RepChaId, this.ForConConfigKey);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Delete() {
            IrisGenerator.Dal.FormaterReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.FormaterReplacementChars();
                dbo.FORMATER_REPLACEMENT_CHARS_Delete(this.RepChaId, this.ForConConfigKey);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
    }
}
